/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.pos.services.impl;

import com.pos.domain.Customer;
import com.pos.ejb.CustomerEJB;
import com.pos.services.CustomerService;
import java.util.List;
import javax.inject.Named;
import javax.ejb.EJB;
import javax.jws.WebMethod;
import javax.jws.WebService;



/**
 *
 * @author Dipendra
 */

@Named
public class CustomerServiceImpl implements CustomerService {

    @EJB
    CustomerEJB customerEJB;
    

    public void save(Customer customer) {
        if (customer.getId() <= 0 || find(customer.getId()) == null) {
            create(customer);
        } else {
            edit(customer);
        }
    }

    public void create(Customer customer) {
        customerEJB.create(customer);
    }

   
    public void edit(Customer customer) {
        customerEJB.edit(customer);
    }

  
    public void remove(Customer customer) {
        customerEJB.remove(customer);
    }

  
    public Customer find(Object id) {
    //    Long tempId = new Long(id.toString());
       return customerEJB.find(new Long(id.toString()));
    }


    public List<Customer> findAll() {
        return customerEJB.findAll();
    }

  
    public List<Customer> findRange(int[] range) {
       return customerEJB.findRange(range);
    }

   
    public int count() {
        return customerEJB.count();
    }

    public Customer getDefault() {
       return null;
    }


}
